<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\Traits\HasDateTimeFormatter;

class StoreGoods extends Model
{
    use HasDateTimeFormatter;

    protected $table = 'ims_yz_store_goods';
    protected $guarded = [''];

    // 禁用Laravel的自动时间戳管理
    public $timestamps = false;

    protected $casts = [
        'goods_id' => 'integer',
        'store_id' => 'integer',
        'status' => 'integer',
        'created_at' => 'integer',
        'updated_at' => 'integer'
    ];

    /**
     * 关联商品
     */
    public function goods()
    {
        return $this->belongsTo(Goods::class, 'goods_id', 'id');
    }

    /**
     * 关联门店
     */
    public function store()
    {
        return $this->belongsTo(Store::class, 'store_id', 'id');
    }
}